<%
#existing project pattern was selected
if phases.length >0
%>

  <% for patterns_phases_row in phases
    #create unique identifier for list item
    i= Time.new
    i = "%10.0f" % i.to_f.to_s + '_' + "%010.0f" %(rand*10000000000).to_f.to_s
  %>

    <li class="sortable" id="<%=i%>">
      <%= hidden_field_tag 'phases[id][]',patterns_phases_row.phase_id %>
      <%= text_field_tag 'phases[name][]',patterns_phases_row.phase.name ,:onkeyup=>"$('input[name=\"phases[id][]\"][value=\"#{patterns_phases_row.phase_id }\"]').attr('value','')" %> Cost Weight % : <%= text_field_tag 'phases[weight][]',patterns_phases_row.weight, :size => 5 %>
      <%= link_to_function image_tag('/images/delete.png',:title=>'Remove',:alt=>'Remove') + "Remove This Phase", "$('##{i}').remove()"%>
    </li>

  <% end %>

  <%
  #no project pattern was selected or added new list item
else
  #create unique identifier for list item
  i= Time.new
  i = "%10.0f" % i.to_f.to_s + '_' + "%010.0f" %(rand*10000000000).to_f.to_s


%>
  <li class="sortable" id="<%=i%>">
    <%= hidden_field_tag 'phases[id][]',nil %>
    <%= text_field_tag 'phases[name][]','Phase 1'%> Cost Weight % : <%= text_field_tag 'phases[weight][]','0', :size => 5%>
    <%= link_to_function image_tag('/images/delete.png',:title=>'Remove',:alt=>'Remove') + "Remove This Phase", "$('##{i}').remove()"%>
  </li>
<% end  %>


